*------------------------------------------------------------------------------*
* Purpose: 		DESCRIPTIVE PLOTS SINHALESE
*------------------------------------------------------------------------------*


*------------------
* Prepare working space
*------------------

set more off
clear


*------------------
* Open cleaned and operationalized survey data
*------------------

use "SL_survey_analysis.dta", clear


	
*------------------	
* Set the data as survey data
*------------------
svyset sl_id 


preserve
drop if a3_ethnic_sinhalese == 0
tab a3_ethnic_sinhalese


*-------------------------------------------------------------------------------
* Figure 4 		
*-------------------------------------------------------------------------------
tab a14_division1, nol
tab a14_division2, nol

gen category = _n if _n<6
recode category (3=1) (1=2) (2=3)

tab a14_division1, matcell(first_option)
matrix list first_option
svmat first_option
egen first_option = sum(first_option1)
replace first_option = round(100* first_option1 / first_option, .1)


	#delimit ;
		graph bar first_option,
			over(category, 
					gap(*8)					
					label(labsize(*1)) 
					relabel(1 "Political" 2 "Religious" 3 "Ethnic" 4 "Economic" 5 "Geographic"))
			ytitle("Percent of Respondents", 
					size(*1.2))
			ylabel(0(10)60, 
					labsize(small) 
					angle(0) 
					nogrid 
					nogmin) 
			bar(1, color(black*0.7)) 
			bar(2, color(black*0.4))
			plotregion(lcolor(black)) 
			graphregion(fcolor(white) 
					ilcolor(white) 
					lcolor(white))
	;
	#delimit cr	
	
	graph export "figure_4.pdf", as(pdf) replace


drop category

drop first_option*




*-------------------------------------------------------------------------------
* Figure 5
*-------------------------------------------------------------------------------

* Set working data
	use "SL_survey_analysis.dta", clear
	svyset sl_id

* Make sure to only have Sinhalese in the data
	drop if a3_ethnic_sinhalese == 0
	tab a3_ethnic_sinhalese


	
gen category = _n if _n<5


tab f1_a, matcell(leaflet)
matrix list leaflet
svmat leaflet
egen leaflet = sum(leaflet1)
replace leaflet = round(100* leaflet1 / leaflet, .1)

tab f1_b, matcell(demo)
matrix list demo
svmat demo
egen demo = sum(demo1)
replace demo = round(100* demo1 / demo, .1)

tab f1_c, matcell(strike)
matrix list strike
svmat strike
egen strike = sum(strike1)
replace strike = round(100* strike1 / strike, .1)

tab f1_d, matcell(damage)
matrix list damage
svmat damage
egen damage = sum(damage1)
replace damage = round(100* damage1 / damage, .1)

tab f1_e, matcell(harm_opponent)
matrix list harm_opponent
svmat harm_opponent
egen harm_opponent = sum(harm_opponent1)
replace harm_opponent = round(100* harm_opponent1 / harm_opponent, .1)

tab f1_f, matcell(harm_state)
matrix list harm_state
svmat harm_state
egen harm_state = sum(harm_state1)
replace harm_state = round(100* harm_state1 / harm_state, .1)

tab f1_g, matcell(harm_bystander)
matrix list harm_bystander
svmat harm_bystander
egen harm_bystander = sum(harm_bystander1)
replace harm_bystander = round(100* harm_bystander1 / harm_bystander, .1)

drop leaflet1 demo1 strike1 damage1 harm_opponent1 harm_state1 harm_bystander1

	
	
** Plot

tab category


#delimit ;
		graph bar leaflet demo strike,
			over(category, 
					gap(*8)					
					label(labsize(*1.1)) 
					relabel(1 "Very unlikely" 2 "Unlikely" 3 "Likely" 4 "Very likely"))
			title("(a) Legitimate actions""", col(black) margin(b=5))
			ytitle("Percent of Respondents", 
					size(*1.2))
			ylabel(0(10)50, 
					labsize(small) 
					angle(0) 
					nogrid 
					nogmin) 
			bar(1, color(navy*0.35)) 
			bar(2, color(navy*0.63)) 
			bar(3, color(navy))
			legend(title("", size(*.75) col(black))
						order(1 "Leaflet" 
							  2 "Demonstration"
							  3 "Strike"
							  )  
						bm(zero) 
						col(1) row(7) 
						colgap(5) 
						keygap(.8)
						size(small) symxsize(4) symysize(2)
						region(lcolor(gs0)) bm(l=12 r=3)
						position(2) ring(0)
						) 			
			plotregion(lcolor(black)) 
			graphregion(fcolor(white) 
					ilcolor(white) 
					lcolor(white))
			saving(Bar1, replace)
	;
	#delimit cr	



	
#delimit ;
		graph bar damage harm_bystander harm_state harm_opponent,
			over(category, 
					gap(*8)					
					label(labsize(*1.1)) 
					relabel(1 "Very unlikely" 2 "Unlikely" 3 "Likely" 4 "Very likely"))
			title("(b) Illegitimate actions" "", col(black)  margin(b=5))
			ytitle("", 
					size(*1.2))
			ylabel(0(10)50, 
					labsize(small) 
					angle(0) 
					nogrid 
					nogmin) 
			bar(1, color(cranberry*0.23))
			bar(2, color(cranberry*0.35)) 
			bar(3, color(cranberry*0.63)) 
			bar(4, color(cranberry))
			legend(title("", size(*.75) col(black))
						order(1 "Damage property"
							  2 "Attack bystander"
							  3 "Attack state"
							  4 "Attack opponent"
							  )  
						bm(zero) 
						col(1) row(7) 
						colgap(5) 
						keygap(.8)
						size(small) symxsize(4) symysize(2)
						region(lcolor(gs0)) bm(l=12 r=3)
						position(2) ring(0)
						) 			
			plotregion(lcolor(black)) 
			graphregion(fcolor(white) 
					ilcolor(white) 
					lcolor(white))
			saving(Bar2, replace)
	;
	#delimit cr	
	

	#delimit ;
	graph combine Bar1.gph Bar2.gph,
					ysize(1) xsize(2) 
					scheme(s1mono)
					saving(figure_5_alt, replace) 
	;
	#delimit cr

	graph export "figure_5_alt.pdf", as(pdf) replace
	
	drop category

	restore

	
clear

erase Bar1.gph 
erase Bar2.gph
erase figure_5_alt.gph

exit

